package com.lifeverse.entity;

import com.lifeverse.entity.enums.ExperienceType;
import com.lifeverse.entity.enums.LearningOutcome;
import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.time.LocalDateTime;

/**
 * 学习经验实体
 * 用于存储生命体的学习经验和知识获取记录
 */
@Entity
@Table(name = "learning_experiences")
@Data
@EqualsAndHashCode(callSuper = true)
public class LearningExperience extends BaseEntity {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 关联的生命体ID
     */
    @Column(name = "life_entity_id", nullable = false)
    private Long lifeEntityId;

    /**
     * 经验类型
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "experience_type", nullable = false)
    private ExperienceType experienceType;

    /**
     * 经验标题
     */
    @Column(name = "title", nullable = false, length = 200)
    private String title;

    /**
     * 经验描述
     */
    @Column(name = "description", columnDefinition = "TEXT")
    private String description;

    /**
     * 学习内容
     */
    @Column(name = "learning_content", columnDefinition = "TEXT")
    private String learningContent;

    /**
     * 学习上下文
     */
    @Column(name = "context", columnDefinition = "TEXT")
    private String context;

    /**
     * 学习结果
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "outcome", nullable = false)
    private LearningOutcome outcome;

    /**
     * 学习效率 (0.0 - 1.0)
     */
    @Column(name = "efficiency", nullable = false)
    private Double efficiency;

    /**
     * 知识保持率 (0.0 - 1.0)
     */
    @Column(name = "retention_rate", nullable = false)
    private Double retentionRate;

    /**
     * 应用成功率 (0.0 - 1.0)
     */
    @Column(name = "application_success_rate")
    private Double applicationSuccessRate;

    /**
     * 学习难度 (1-10)
     */
    @Column(name = "difficulty_level", nullable = false)
    private Integer difficultyLevel;

    /**
     * 重要性评分 (0.0 - 1.0)
     */
    @Column(name = "importance_score", nullable = false)
    private Double importanceScore;

    /**
     * 学习开始时间
     */
    @Column(name = "started_at", nullable = false)
    private LocalDateTime startedAt;

    /**
     * 学习结束时间
     */
    @Column(name = "completed_at")
    private LocalDateTime completedAt;

    /**
     * 学习持续时间（分钟）
     */
    @Column(name = "duration_minutes")
    private Integer durationMinutes;

    /**
     * 前置知识要求
     */
    @Column(name = "prerequisites", length = 500)
    private String prerequisites;

    /**
     * 获得的技能
     */
    @Column(name = "acquired_skills", length = 500)
    private String acquiredSkills;

    /**
     * 相关经验ID列表
     */
    @Column(name = "related_experience_ids", length = 500)
    private String relatedExperienceIds;

    /**
     * 应用次数
     */
    @Column(name = "application_count", nullable = false)
    private Integer applicationCount = 0;

    /**
     * 最后应用时间
     */
    @Column(name = "last_applied_at")
    private LocalDateTime lastAppliedAt;

    /**
     * 遗忘曲线参数
     */
    @Column(name = "forgetting_curve_params", length = 200)
    private String forgettingCurveParams;

    /**
     * 强化学习次数
     */
    @Column(name = "reinforcement_count", nullable = false)
    private Integer reinforcementCount = 0;

    /**
     * 扩展属性（JSON格式）
     */
    @Column(name = "metadata", columnDefinition = "TEXT")
    private String metadata;
}